package dao.impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import dao.DriverStateDao;
import dao.RowMapper;
import entity.DriverState;
//HanMans
public class DriverStateDaoImpl implements DriverStateDao {
	JDBCTemplate jdbc = new JDBCTemplate();
	private class rowMapperImpl implements RowMapper<DriverState>{
		@Override
		public DriverState rowMapper(ResultSet rs) throws SQLException {
			//dsId, stateName, driverList
			return new DriverState(rs.getInt("dsId"),rs.getString("stateName"),null);
		}
	}
	
	@Override
	public List<DriverState> queryAllDriverState() {
		return jdbc.queryAll("select * from DriverState",new rowMapperImpl());
	}

	@Override
	public DriverState queryDriverState(int driverStateId) {
		return jdbc.queryOne("select * from DriverState where dsId=?", new rowMapperImpl(), driverStateId);
	}

}
